import React, { Component } from 'react'
import {View,Text,ScrollView,Image} from 'react-native'
import DatePicker from 'antd-mobile-rn/lib/date-picker';

import List from 'antd-mobile-rn/lib/list'
import Picker from'antd-mobile-rn/lib/picker'

export default class Test extends Component {
  constructor(props){
      super(props)
      this.state = {
        date:'',
        visible:false,
        pickerValue:''
      }
    }
    handAge = (date) => {
      // let str = age.toLocaleDateString()
      this.setState({
        date:date
      })
    }
    handCity = (res) => {
      console.log(res)
      this.setState({
        pickerValue:res
      })
    }
  render() {
    console.log(this.state.age)
    return (
      <View style={{}}>
        <View style={{padding:20}}>
          <DatePicker
            mode="date"
            title="选择出生生日期"
            extra="请选择"
            value={this.state.date}
            onChange={this.handAge}
            
          >
            <List.Item arrow="horizontal"><Text>生日</Text></List.Item>
          </DatePicker>
        </View>
        <View style={{padding:20}}>
          <Picker
            visible={this.state.visible}
            data={province}
            value={this.state.pickerValue}
            onChange={this.handCity}
            onOk={() => this.setState({ visible: false })}
            onDismiss={() => this.setState({ visible: false })}
          >
            <List.Item  onClick={() => this.setState({ visible: true })}>
              长居城市
            </List.Item>
         </Picker>
        </View>
        
      </View>
    )
  }
}
const province = [
  {
    label: '北京',
    value: '北京',
    children: [
      {
        label: '东城区',
        value: '东城区',
      },
      {
        label: '西城区',
        value: '01-2',
      },
      {
        label: '崇文区',
        value: '01-3',
      },
      {
        label: '宣武区',
        value: '01-4',
      },
    ],
  },
  {
    label: '浙江',
    value: '02',
    children: [
      {
        label: '杭州',
        value: '02-1',
      },
      {
        label: '宁波',
        value: '02-2',

      },
      {
        label: '温州',
        value: '02-3',
      },
      {
        label: '嘉兴',
        value: '02-4',
      },
      {
        label: '湖州',
        value: '02-5',
      },
      {
        label: '绍兴',
        value: '02-6',
      },
    ],
  },
];
